using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Data.Models.Mapping
{
    public class CompanyMap : EntityTypeConfiguration<Company>
    {
        public CompanyMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.DisplayName)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.TradingName)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.Logo)
                .HasMaxLength(1000);

            this.Property(t => t.Business)
                .IsRequired()
                .HasMaxLength(1000);

            this.Property(t => t.OrgaType)
                .HasMaxLength(250);

            this.Property(t => t.Description)
                .HasMaxLength(1000);

            this.Property(t => t.PostAttention)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.PostAddress)
                .IsRequired()
                .HasMaxLength(1000);

            this.Property(t => t.Tel_Num)
                .HasMaxLength(40);

            this.Property(t => t.Email)
                .HasMaxLength(250);

            this.Property(t => t.Website)
                .HasMaxLength(250);

            // Table & Column Mappings
            this.ToTable("Companies");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.ParentID).HasColumnName("ParentID");
            this.Property(t => t.DisplayName).HasColumnName("DisplayName");
            this.Property(t => t.TradingName).HasColumnName("TradingName");
            this.Property(t => t.Logo).HasColumnName("Logo");
            this.Property(t => t.Business).HasColumnName("Business");
            this.Property(t => t.OrgaType).HasColumnName("OrgaType");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.PostAttention).HasColumnName("PostAttention");
            this.Property(t => t.PostAddress).HasColumnName("PostAddress");
            this.Property(t => t.Tel_Num).HasColumnName("Tel_Num");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Website).HasColumnName("Website");
        }
    }
}
